package com.api.shopapi.mapper;


import com.api.shopapi.entity.Remind;
import com.api.shopapi.entity.dto.RemindDTO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
@Mapper
public interface RemindMapper {


    @Delete("delete from remind where RemindCode=#{remindCode}")
    public int delete(@Param("remindCode") String remindCode);

    @Update("update remind " +
            "set " +
            "RemindCode = #{remind.RemindCode}," +
            "UserCode = #{remind.UserCode}," +
            "Remarks = #{remind.Remarks}," +
            "CreateTime = #{remind.CreateTime}," +
            "Status = #{remind.Status}," +
            "GovernmentCode = #{remind.GovernmentCode},"+
            "RemindType = #{remind.RemindType} "+
            "where RemindCode=#{remind.RemindCode}")
    public int update(@Param("remind") Remind remind);

    @Select("select * from remind  order by CreateTime desc")
    public List<Remind> getList();

    @Select("select * from remind where RemindCode=#{remindCode} limit 1")
    public Remind getByRemindCode(@Param("remindCode") String remindCode);



    @Select("select * from remind where UserCode = #{userCode} order by CreateTime desc")
    public List<Remind> getListByUserCode(String userCode);


    @Insert("insert into remind (RemindCode,UserCode,Remarks,CreateTime,Status,GovernmentCode,RemindType) " +
            "value(#{remind.RemindCode},#{remind.UserCode}," +
            "#{remind.Remarks},#{remind.CreateTime},#{remind.Status},"+
            "#{remind.GovernmentCode},#{remind.RemindType})")
    public int insert(@Param("remind") Remind remind);

    @Select("select * from remind where GovernmentCode=#{governmentCode} and (CreateTime between #{startTime} and #{endTime}) and RemindType=1 order by CreateTime desc  ")
    List<RemindDTO> getPageList(@Param("governmentCode") String governmentCode, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
}
